import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 能源设备信息 */
export interface EnergyEquipment {
          mac: string; // 表号
          id: number; // 编号
          dormitoryId?: number; // 宿舍编号
          type?: number; // 类型：空调0，照明1，水2
          price?: number; // 价格
          gatewayId: number; // 网关
          isRemote: number; // 是否远程控制（开启1，关闭0）
  }

// 能源设备 API
export const EnergyEquipmentApi = {
  // 查询能源设备分页
  getEnergyEquipmentPage: async (params: any) => {
    return await request.get({ url: `/dorm/energy-equipment/page`, params })
  },

  // 查询能源设备详情
  getEnergyEquipment: async (id: number) => {
    return await request.get({ url: `/dorm/energy-equipment/get?id=` + id })
  },

  // 新增能源设备
  createEnergyEquipment: async (data: EnergyEquipment) => {
    return await request.post({ url: `/dorm/energy-equipment/create`, data })
  },

  // 修改能源设备
  updateEnergyEquipment: async (data: EnergyEquipment) => {
    return await request.put({ url: `/dorm/energy-equipment/update`, data })
  },

  // 删除能源设备
  deleteEnergyEquipment: async (id: number) => {
    return await request.delete({ url: `/dorm/energy-equipment/delete?id=` + id })
  },

  /** 批量删除能源设备 */
  deleteEnergyEquipmentList: async (ids: number[]) => {
    return await request.delete({ url: `/dorm/energy-equipment/delete-list?ids=${ids.join(',')}` })
  },

  // 导出能源设备 Excel
  exportEnergyEquipment: async (params) => {
    return await request.download({ url: `/dorm/energy-equipment/export-excel`, params })
  },
}